Public Class ProfitabilityReport_Excel
    Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If Not Page.IsPostBack Then
            If Not IsNothing(Session(ProfitabilityReport.PROFITABILITY_REPORT_SESSION_NAME)) Then

                With CType(Session(ProfitabilityReport.PROFITABILITY_REPORT_SESSION_NAME), CProfitabilityReport)
                    .Output = Report.EReportOutputType.File
                    '.RefreshReport()
                    'output to user
                    Response.Clear()
                    Response.ContentType = "application/x-msexcel"
                    Response.AddHeader("content-disposition", "filename=""" & "PR" & GetRandomFileName())
                    'Response.Write(.GetReportHTML)
                    Response.End()
                    'Response.Write(.CustomerID)
                End With

            Else
                Throw New ApplicationException("Session expired. Please go to Profitability Report page")
            End If
        End If
    End Sub

End Class
